package de.hijacksoft.isle.classes;

import android.graphics.Color;

public class Category {

    public static final int UNCATEGORIZED = -1;
    public static final int NEW_CATEGORY = -2;
    public static final int RECIPE = -3;
    public static final int ADD_CATEGORY = -3;
    public static final int COLOR_RANDOM = -1;
    public int id = -3;
    public int color = 0x000000;
    public String name = null;
    public boolean isRecipe = false;

    public Category() {
        int r, g, b;
        // random color for the new category
        r = (int) (Math.random() * 255);
        g = (int) (Math.random() * 255);
        b = (int) (Math.random() * 255);
        color = Color.rgb(r, g, b);
    }

    public Category(int id, String name, int color) {
        this.id = id;
        this.name = name;
        if (color < 0) {
            int r, g, b;
            // random color for the new category
            r = (int) (Math.random() * 255);
            g = (int) (Math.random() * 255);
            b = (int) (Math.random() * 255);
            color = Color.rgb(r, g, b);
        } else {
            this.color = color;
        }
    }

    public Category(int id, String name, int color, boolean isRecipe) {
        this.id = id;
        this.name = name;
        if (color < 0) {
            int r, g, b;
            // random color for the new category
            r = (int) (Math.random() * 255);
            g = (int) (Math.random() * 255);
            b = (int) (Math.random() * 255);
            color = Color.rgb(r, g, b);
        } else {
            this.color = color;
        }
        this.isRecipe = isRecipe;
    }

    @Override
    public String toString() {
        return name;
    }
}
